﻿@model IEnumerable<OMS.Models.ItemModelView>
@using OMS.Models

@{
    ViewBag.Title = "Filter";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#item_table tbody tr').click(function () {
            $('#item_table').css('background-color', '#fff');
            $(this).css('background-color', '#abc');
            var id = $(this).find("#item_Id").attr("value");
            var name = $(this).find("#item_Name").text();
            var price = $(this).find("#item_Price").attr("value");
            $('#item_description #item_id').attr('value', id);
            $('#item_description #item_name').text(name);
            $('#item_description #item_price').text(price);
        });
    });
</script>

<h2>Filter</h2>

@using (Html.BeginForm())
{
    <form>
        <select name="filterBy">
            <option value="name" selected>name</option>
            <option value="description">desctiption</option>
        </select>
        @Html.TextBox("SearchString")
        <input type="submit" value="Search" />
    </form>
}
<table align=center id="item_table">
<tr>
    <th>Name</th>
    <th>Description</th>
</tr>
@foreach (var item in Model)
{
    <tr>
        @Html.HiddenFor(i => item.Id)
        <td id="item_Name">
            @Html.DisplayFor(i => item.Name)
        </td>
        <td id="item_Description">
            @Html.DisplayFor(i => item.Description)
        </td>
        @Html.HiddenFor(i => item.Price)
        
    </tr>
}
</table>
<table id="item_description" align=center>
    <hidden name="item_id" id="item_id"></hidden>
    <tr>
        <td>Name</td>
        <td id="item_name"></td>
    </tr>
    <tr>
        <td>Price</td>
        <td id="item_price"></td>
    </tr>
    <tr>
        <td>Quantity</td>
        <td>@Html.Editor("quantity")</td>
    </tr>
    <tr>
        <td>Dimension</td>
        <td>
            <select name="dimension">
                <option value="item" selected>Item</option>
                <option value="box">Box</option>
                <option value="package">Package</option>
            </select>
        </td>
    </tr>
</table>
<button>Remove</button>
<button>Done</button>
<button>Cancel</button>